%%%-------------------------------------------------------------------
%%% @author kk
%%% @copyright (C) 2024, <COMPANY>
%%% @doc
%%% 移除元组或列表中指定位置的元素
%%% @end
%%% Created : 19. 7月 2024 12:20
%%%-------------------------------------------------------------------
-module(d8).
-author("kk").

%% API
-export([removeIndexElement/1, removeIndexElement/2]).

removeIndexElement([]) -> [].
removeIndexElement(List, Index) -> removeIndexElement(List, Index, 1).
removeIndexElement([], Index, I) -> [];
removeIndexElement([H | List], Index, I) ->
  if
    Index /= I -> io:fwrite("list：~w index：~w ~n", [H, I]), [H | removeIndexElement(List, Index, I + 1)];
    true -> removeIndexElement(List, Index, I + 1) % [5] 4 5
  end.

